package com.fu.web.controler;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.fu.web.DTO.loginForm;
import com.fu.web.service.loginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.swing.plaf.synth.SynthSpinnerUI;

@RestController
@RequestMapping("/loginControl")
public class loginControler {
@Autowired
    private loginService loginService;
private static int checkCode=0;
@PostMapping("/loginCheck")
    public int loginCheck(@RequestBody loginForm form){
    String tempName=form.getUsername();
    String tempPwd=form.getPass();
    if (loginService.checkDoc(tempName,tempPwd)!=null){
        checkCode=1;
        return checkCode;
    }
    else if(loginService.checkPharmacy(tempName,tempPwd)!=null){
        checkCode=2;

        return checkCode;
    }
    else if(loginService.checkStaff(tempName,tempPwd)!=null){
        checkCode=3;

        return checkCode;
    }

    return checkCode;

}

}
